import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BaseinfoDemandRecordApi } from '#/api/csyt/baseinfodemandrecord';

import { z } from '#/adapter/form';
import {
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'demandName',
      label: '需求名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入需求名称',
      },
    },
    {
      fieldName: 'demandNo',
      label: '需求编码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入需求编码',
      },
    },
    {
      fieldName: 'companyName',
      label: '企业名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入企业名称',
      },
    },
    {
      fieldName: 'demandStatus',
      label: '需求状态',
      component: 'RadioGroup',
      componentProps: {
        options: [],
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'phone',
      label: '联系电话',
      component: 'Input',
      componentProps: {
        placeholder: '请输入联系电话',
      },
    },
    {
      fieldName: 'userName',
      label: '用户名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入用户名称',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'demandName',
      label: '需求名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入需求名称',
      },
    },
    {
      fieldName: 'demandNo',
      label: '需求编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入需求编码',
      },
    },
    {
      fieldName: 'companyName',
      label: '企业名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入企业名称',
      },
    },
    {
      fieldName: 'demandStatus',
      label: '需求状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: [],
        placeholder: '请选择需求状态',
      },
    },
    {
      fieldName: 'phone',
      label: '联系电话',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入联系电话',
      },
    },
    {
      fieldName: 'userName',
      label: '用户名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入用户名称',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BaseinfoDemandRecordApi.BaseinfoDemandRecord>['columns'] {
  return [
  { type: 'checkbox', width: 40 },
    {
      field: 'id',
      title: '序号',
      minWidth: 120,
    },
    {
      field: 'demandName',
      title: '需求名称',
      minWidth: 120,
    },
    {
      field: 'demandNo',
      title: '需求编码',
      minWidth: 120,
    },
    {
      field: 'companyName',
      title: '企业名称',
      minWidth: 120,
    },
    {
      field: 'demandStatus',
      title: '需求状态',
      minWidth: 120,
    },
    {
      field: 'phone',
      title: '联系电话',
      minWidth: 120,
    },
    {
      field: 'userName',
      title: '用户名称',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
